# Generated by Django 1.11.4 on 2017-08-30 13:17
from __future__ import unicode_literals

from django.db import migrations, models


def vsow_to_hw(apps, schema_editor):
    # We can't import the Season model directly as it may be a newer
    # version than this migration expects. We use the historical version.
    Season = apps.get_model("challenge", "Season")
    for season in Season.objects.all():
        cantons = ["WS" if c == "VS-OW" else c for c in season.cantons]
        season.cantons = cantons
        season.save()


def hw_to_vsow(apps, schema_editor):
    # We can't import the Season model directly as it may be a newer
    # version than this migration expects. We use the historical version.
    Season = apps.get_model("challenge", "Season")
    for season in Season.objects.all():
        cantons = ["VS-OW" if c == "WS" else c for c in season.cantons]
        season.cantons = cantons
        season.save()


class Migration(migrations.Migration):
    dependencies = [
        ("challenge", "0042_auto_20170829_1438"),
    ]

    operations = [
        migrations.RunPython(vsow_to_hw, hw_to_vsow),
        migrations.AlterField(
            model_name="season",
            name="cantons",
            field=models.CharField(
                choices=[
                    ("AR", "Appenzell Ausserrhoden"),
                    ("BE", "Berne"),
                    ("BS", "Basel-Stadt"),
                    ("FR", "Fribourg"),
                    ("GE", "Geneva"),
                    ("JU", "Jura"),
                    ("LU", "Lucerne"),
                    ("NE", "Neuchatel"),
                    ("SG", "St. Gallen"),
                    ("VD", "Vaud"),
                    ("VS", "Valais"),
                    ("WS", "Haut-Valais"),
                    ("ZH", "Zurich"),
                ],
                max_length=38,
                verbose_name="Cantons",
            ),
        ),
    ]
